def calc_iou_thresh(n=7):
    if n < 2: raise Exception("ERROR")
    return (n-1)**2 / (2 * n**2 - (n-1)**2)

def get_evaluate_format(rec,prec,ap):
    if rec < 0.0001:
        if prec < 0.0001:
            if ap < 0.0001:
                format_str = "\n(%s) EVAL RESULTS|instances: %d, recall@50: %.4e, precision@50: %.4e, AP@50: %.4e"
            else:
                format_str = "\n(%s) EVAL RESULTS|instances: %d, recall@50: %.4e, precision@50: %.4e, AP@50: %.4f"
        else:
            if ap < 0.0001:
                format_str = "\n(%s) EVAL RESULTS|instances: %d, recall@50: %.4e, precision@50: %.4f, AP@50: %.4e"
            else:
                format_str = "\n(%s) EVAL RESULTS|instances: %d, recall@50: %.4e, precision@50: %.4f, AP@50: %.4f"
    else:
        if prec < 0.0001:
            if ap < 0.0001:
                format_str = "\n(%s) EVAL RESULTS|instances: %d, recall@50: %.4f, precision@50: %.4e, AP@50: %.4e"
            else:
                format_str = "\n(%s) EVAL RESULTS|instances: %d, recall@50: %.4f, precision@50: %.4e, AP@50: %.4f"
        else:
            if ap < 0.0001:
                format_str = "\n(%s) EVAL RESULTS|instances: %d, recall@50: %.4f, precision@50: %.4f, AP@50: %.4e"
            else:
                format_str = "\n(%s) EVAL RESULTS|instances: %d, recall@50: %.4f, precision@50: %.4f, AP@50: %.4f"
    
    return format_str